import { ref , onMounted } from "vue";
import type { Menu } from '@/interface/Menu';
import { useLoginStore } from "@/stores/loginStore"

export default function () {

    const menus  = ref([
        {
            id: '1',
            menuName : '首页',
            pId: '0',
            name: '',
            type : 0,
            url: '/index/home',
            isExternalLink : 0,
            icon: '2024/04/08/89d2a32d8e804da68e62e9d758d0eaf0.png',
            sortOrder: 0,
            status : 0,
            permissionCode: '',
            remark: '',
            children: []
        }
    ] as Menu[]);

    const loginStore = useLoginStore();

    onMounted(()=> {
        setMenu();
    });


    function setMenu() {
        if (loginStore.loginInfo.user) {
            menus.value = [...menus.value, ...loginStore.loginInfo.user.authMenus];
        }
    }

    return {
        menus
    }
}
